using IrisGenerator.Common.Tools;
namespace IrisGenerator.Common.Modules
{
    
    
    public partial class ReplacementChars {
        
        private System.Nullable<System.Guid> _repChaId;
        
        private string _repChaOriginal;
        
        private string _repChaReplace;
        
        private FormaterReplacementCharsCollection _formaterReplacementCharsCollection;
        
        public virtual System.Nullable<System.Guid> RepChaId {
            get {
                return _repChaId;
            }
            set {
                _repChaId = value;
            }
        }
        
        public virtual string RepChaOriginal {
            get {
                return _repChaOriginal;
            }
            set {
                _repChaOriginal = value;
            }
        }
        
        public virtual string RepChaReplace {
            get {
                return _repChaReplace;
            }
            set {
                _repChaReplace = value;
            }
        }
        
        public virtual FormaterReplacementCharsCollection FormaterReplacementCharsCollection {
            get {
                if ((this._formaterReplacementCharsCollection == null)) {
                    _formaterReplacementCharsCollection = FormaterReplacementChars.Select_FORMATER_REPLACEMENT_CHARS_By_REP_CHA_ID(this.RepChaId);
                }
                return this._formaterReplacementCharsCollection;
            }
        }
        
        private void Clean() {
            this.RepChaId = null;
            this.RepChaOriginal = string.Empty;
            this.RepChaReplace = string.Empty;
            this._formaterReplacementCharsCollection = null;
        }
        
        private void Fill(System.Data.DataRow dr) {
            this.Clean();
            if ((dr["REP_CHA_ID"] != System.DBNull.Value)) {
                this.RepChaId = ((System.Nullable<System.Guid>)(dr["REP_CHA_ID"]));
            }
            if ((dr["REP_CHA_ORIGINAL"] != System.DBNull.Value)) {
                this.RepChaOriginal = ((string)(dr["REP_CHA_ORIGINAL"]));
            }
            if ((dr["REP_CHA_REPLACE"] != System.DBNull.Value)) {
                this.RepChaReplace = ((string)(dr["REP_CHA_REPLACE"]));
            }
        }
        
        public static ReplacementCharsCollection GetAll() {
            IrisGenerator.Dal.ReplacementChars dbo = null;
            try {
                dbo = new IrisGenerator.Dal.ReplacementChars();
                System.Data.DataSet ds = dbo.REPLACEMENT_CHARS_Select_All();
                ReplacementCharsCollection collection = new ReplacementCharsCollection();
                if (GlobalTools.IsSafeDataSet(ds)) {
                    for (int i = 0; (i < ds.Tables[0].Rows.Count); i = (i + 1)) {
                        ReplacementChars obj = new ReplacementChars();
                        obj.Fill(ds.Tables[0].Rows[i]);
                        if ((obj != null)) {
                            collection.Add(obj);
                        }
                    }
                }
                return collection;
            }
            catch (System.Exception ) {
                throw;
            }
            finally {
                if ((dbo != null)) {
                    dbo.Dispose();
                }
            }
        }
        
        public static ReplacementChars Load(System.Nullable<System.Guid> REP_CHA_ID) {
            IrisGenerator.Dal.ReplacementChars dbo = null;
            try {
                dbo = new IrisGenerator.Dal.ReplacementChars();
                System.Data.DataSet ds = dbo.REPLACEMENT_CHARS_Select_One(REP_CHA_ID);
                ReplacementChars obj = null;
                if (GlobalTools.IsSafeDataSet(ds)) {
                    if ((ds.Tables[0].Rows.Count > 0)) {
                        obj = new ReplacementChars();
                        obj.Fill(ds.Tables[0].Rows[0]);
                    }
                }
                return obj;
            }
            catch (System.Exception ) {
                throw;
            }
            finally {
                if ((dbo != null)) {
                    dbo.Dispose();
                }
            }
        }
        
        public virtual void Load() {
            IrisGenerator.Dal.ReplacementChars dbo = null;
            try {
                dbo = new IrisGenerator.Dal.ReplacementChars();
                System.Data.DataSet ds = dbo.REPLACEMENT_CHARS_Select_One(this.RepChaId);
                if (GlobalTools.IsSafeDataSet(ds)) {
                    if ((ds.Tables[0].Rows.Count > 0)) {
                        this.Fill(ds.Tables[0].Rows[0]);
                    }
                }
            }
            catch (System.Exception ) {
                throw;
            }
            finally {
                if ((dbo != null)) {
                    dbo.Dispose();
                }
            }
        }
        
        public virtual void Insert() {
            IrisGenerator.Dal.ReplacementChars dbo = null;
            try {
                dbo = new IrisGenerator.Dal.ReplacementChars();
                dbo.REPLACEMENT_CHARS_Insert(this.RepChaOriginal, this.RepChaReplace);
            }
            catch (System.Exception ) {
                throw;
            }
            finally {
                if ((dbo != null)) {
                    dbo.Dispose();
                }
            }
        }
        
        public virtual void Delete() {
            IrisGenerator.Dal.ReplacementChars dbo = null;
            try {
                dbo = new IrisGenerator.Dal.ReplacementChars();
                dbo.REPLACEMENT_CHARS_Delete(this.RepChaId);
            }
            catch (System.Exception ) {
                throw;
            }
            finally {
                if ((dbo != null)) {
                    dbo.Dispose();
                }
            }
        }
        
        public virtual void Update() {
            IrisGenerator.Dal.ReplacementChars dbo = null;
            try {
                dbo = new IrisGenerator.Dal.ReplacementChars();
                dbo.REPLACEMENT_CHARS_Update(this.RepChaId, this.RepChaOriginal, this.RepChaReplace);
            }
            catch (System.Exception ) {
                throw;
            }
            finally {
                if ((dbo != null)) {
                    dbo.Dispose();
                }
            }
        }
    }
}
